<%-- 
    Document   : search
    Created on : Apr 11, 2013, 11:51:25 AM
    Author     : mona.chandrapal
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Search</title>
<%@include file="header.jsp"%>



<script>

function viewdetails(issueid) {
	//alert("View details: " + issueid);
	window.location = "viewissue.jsp?issueid=" + issueid;
	//+ issueid;

}

	function SearchPageInit(searchstr) {
		// alert("PageLoad: " + searchstr);
		$
				.ajax({
					type : "post",
					url : "../searchIssue",
					datatype : "json",
					data : "searchstr="+searchstr ,
					success : function(data) {
						if (data.issuedetails.length > 0) {

							$("#issuelist").html("<div  >");
							var i;
							for (i = 0; i < data.issuedetails.length; i++) {

								var bugid = "N.A.";
								var module = "N.A.";
								var category = "N.A.";
								var subcategory = "N.A.";
								var version =" N.A.";
								
								if (data.issuedetails[i].bugid.length > 0) {
									bugid = data.issuedetails[i].bugid;
								}
								if (data.issuedetails[i].module.length >0) {
									module = data.issuedetails[i].module;
								}
								if (data.issuedetails[i].category.length >0) {
									category = data.issuedetails[i].category;
								}
								if (data.issuedetails[i].subcategory.length >0) {
									subcategory = data.issuedetails[i].subcategory;
								}
								if (data.issuedetails[i].version.length >0 ) {
									version = data.issuedetails[i].version;
								}

								$("#issuelist")
										.append(
												"<div><div  class=\"myissue\"  ondblclick=\"viewdetails('"+ data.issuedetails[i].id + "')\"  > <table  border=\"0\" width=\"100%\"><tr><td style=\"padding-top: 5px; padding-left: 5px; font-size: 18px;\" colspan=\"3\"  >"
														+"<span style=\"color: black\"> </span>" 
														+data.issuedetails[i].issuetitle + "<br/>"
														+"</tr><tr><td style=\"padding-bottom: 5px; padding-left: 5px; font-size: 12px; \" colspan=\"3\">"
														+ "by <span style=\"color: blue\" > " + data.issuedetails[i].createdby
														+ "</span> on "
														+ data.issuedetails[i].createdon
														+ "</td></tr><tr><td style=\"padding-bottom: 5px; padding-left: 5px; padding-top:5px; width: 30% \">Bugid: "
														+ bugid 
														+ "</td><td style=\"padding-bottom: 5px; padding-left: 5px; padding-top:5px; \">Module: "
														+ module +" --> "
														+ category +" --> "
														+ subcategory
														+ "</td></tr><tr><td style=\"padding-bottom: 5px; padding-left: 5px; padding-top:5px; \">Version: "
														 + version
														+ "</td></tr>"
														//+"<tr><td style=\"padding-top: 5px;	padding-left: 5px;\" colspan=\"3\" ><hr>"
														//+ data.issuedetails[i].issuedetails.substring(0,200)+ "</td></tr>"
														+"</div></table></div></div> <br/>"
// 														+ "<div style=\" \">"
// 														+ "<span style=\"padding-left: 5px;\"> Comment</span><span style=\"padding-left: 20px;\"> Like</span>"
// 														+"<span	class=\"pull-right\" style=\"padding-right: 30px;\"> "
// 														+"<img src=\"../images/like.png\" alt=\" \" style=\"padding-bottom: 5px;\" width=\"24\" height=\"24\" /> 7"
// 														+"&nbsp;&nbsp;<img src=\"../images/comment.png\" alt=\"\" style=\"padding-bottom: 5px;\	width=\"24\" height=\"24\" /> 5 </span></div></div> <br/>"
																										
														);
							}

							
						}

						
						$("#issuelist").append("</div>");
					},
					error : function(jqXHR, textStatus) {
						alert("Error viewing article: " + textStatus);
					}
				});

	};
</script>

</head>
<%@include file="toppanel.jsp"%>

<body onload="SearchPageInit('<%=request.getParameter("searchstr") %>')">



	<div style="text-align: center">
		<h3>Search Results</h3>
	</div>
	
	<div style="padding-left: 10%; padding-right: 10%">
		<div id="issuelist"></div>
	</div>





</body>
</html>
